package sv.gob.mh.dgii.dao.ruc;

import org.hibernate.Query;


import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import sv.gob.mh.dgii.dao.hibernate.HibernateDaoNoCrudImpl;
import sv.gob.mh.dgii.model.RcCaractTrib;


@Repository
@Transactional
public class QueryRcCaractTribImpl extends HibernateDaoNoCrudImpl implements QueryRcCaractTrib {

	/**
	 * Metodo de busqueda para consulta ruc con paginacion incluida
	 */
	@Override
	public RcCaractTrib obtenerCaracterTributarioPorNIT(String nit){
            String jpql = "SELECT o FROM RcCaractTrib o WHERE o.rcRuc.nit = :nit and o.bstatus = :activo";
            
            Query q = getSessionFactory().getCurrentSession().createQuery(jpql);
            q.setParameter("nit", nit);
            q.setParameter("activo", true);
            return (RcCaractTrib) q.uniqueResult();
        }
}
